<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>测试页面</title>
    <link rel="stylesheet" type="text/css" href="../css/easyui/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="../css/easyui/icon.css">
    <script src="../js/jquery/jquery.min.js"></script>
    <script src="../js/easyui/jquery.easyui.min.js"></script>
</head>
<body>
<h2>Custom DataGrid Pager</h2>
<p>You can append some buttons to the standard datagrid pager bar.</p>
<label id="label1"><a>11</a></label>
<input id="input2" type="text" value="测试">
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="fz()">赋值</a>
<table id="dg">
    <tr>
        <th>11</th>
        <th>12</th>
        <th>13</th>
        <th>14</th>
    </tr>
    <tr>
        <td>21</td>
        <td>22</td>
        <td>23</td>
        <td>24</td>
    </tr>
    <tr>
        <td>31</td>
        <td>32</td>
        <td>33</td>
        <td>34</td>
    </tr>
</table>
<table id="ddList" title="Custom DataGrid Pager" style="width:50%;height:350px"
       data-options="rownumbers:true,singleSelect:true,pagination:true,url:'/customer/getCustomers',method:'get'">
    <thead>
    <tr>
        <th data-options="field:'id',width:80,checkbox:true">ID</th>
        <th data-options="field:'customerName',width:100">客户姓名</th>
        <th data-options="field:'oddNumber',width:80,align:'right'">订单号</th>
        <th data-options="field:'prices',width:70,align:'right'">价格</th>
        <th data-options="field:'qrId',width:100">二维码信息</th>
    </tr>
    </thead>
</table>
<div>
    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="js_xh()">js循环</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="jq_xh()">jq循环</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="datagrid_xh()">datagrid循环</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="sxfz()">属性赋值</a>
</div>
<script>
    $(function () {
        var pager = $('#ddList').datagrid().datagrid('getPager');

        //调用方法
        var value = getValue("2000","jjr_zjlx");
        console.log(value);
        //判断js类型
        var string = "111";
        var int = 111;
        console.log(typeof string);
        console.log(typeof int);
        console.log(string==int);
        console.log(string===int);
        var yddh = "1235";
        yddh = null;
        console.log(typeof yddh);
        console.log(yddh==null);
    });
    function getValue(key,dicname) {
        var dic;
        if(dicname=="jjr_xb"){
            dic = {"2101":"男","2102":"女"};
        }else if(dicname=="jjr_zjlx"){
            dic = {"2000":"身份证","2001":"户口本","2002":"护照","2003":"军官证","2004":"士兵证","2005":"港澳居民来往内地通行证","2006":"台湾同胞来往内地通行证","2007":"临时身份证","2008":"外国人居留证","2009":"警官证","2010":"港澳台证件","2011":"回乡证","2012":"驾驶证","2015":"其他个人证件","2016":"律师证"};
        }else if(dicname=="jjr_gzqk"){//供职情况
            dic = {"2301":"专职","2302":"兼职"};
        }else if(dicname=="jjr_whcd"){
            dic = {"2401":"小学","2402":"初中","2405":"大专","2404":"中专","2403":"高中","2406":"大学","2408":"博士","2407":"硕士","2499":"其他"};
        }else if(dicname=="jjr_dqzt"){//当前状态
            dic = {"7501":"正常","7502":"处罚","7503":"吊销","7504":"终止","7505":"证书到期","7506":"待注册","7507":"注销"};
        }else if(dicname=="jjr_sfyz"){//身份证校验是否通过
            dic = {"0":"通过","1":"不通过"};
        }else if(dicname=="jjr_gj"){//国籍
            dic = {"4001":"中国","4002":"美国","4009":"法国","4004":"日本","4005":"澳大利亚","4007":"德国","4008":"英国","4010":"韩国","4011":"新加坡","4012":"马来西亚","4014":"俄罗斯","4003":"加拿大","4006":"意大利","4013":"泰国","4015":"其他国籍"};
        }
        console.log(dic);
        return dic[key];
    }
    function fz() {
        //js/jq方式给label,input赋值
        var b = 2;
        var name = "#label"+(b-1)+" a";
        // var a = document.getElementById("label"+(b-1)).innerHTML;
        var a = $(name).html();
        $(name).html(1);
        console.log(a);
        var aa = document.getElementById("input2").value;
        document.getElementById("input2").value = "测试1";
        console.log(aa);
    }
    function js_xh() {
        var tb = document.getElementById('dg');// table 的 id
        var rows = tb.rows;// 获取表格所有行
        for(var i = 0; i<rows.length; i++ ){
            for(var j = 0; j<rows[i].cells.length; j++ ){// 遍历该行的 td
                console.log("第"+(i+1)+"行，第"+(j+1)+"个td的值："+rows[i].cells[j].innerHTML+"。");// 输出每个td的内容
            }
        }
    }
    function jq_xh() {
        var data = {};
        $('#dg tr').each(function(i){// 遍历 tr
            $(this).children('th,td').each(function(j){// 遍历 tr 的各个 td
                console.log("第"+(i+1)+"行，第"+(j+1)+"个td的值："+$(this).text()+"。");
                if(j%4==3){
                    console.log("第"+(i+1)+"行，第"+(j+1)+"个td的值："+$(this).text()+"。");
                    data[i] = $(this).text();
                }
            });
        });
        console.log(data);
    }
    function datagrid_xh() {
        var ceshi = {};
        var rows=$("#ddList").datagrid('getRows');
        for(var i=0;i<rows.length;i++){
            var id=rows[i]['prices'];//获取指定列
            ceshi[i] = id;
        }
        console.log(ceshi);
    }
    function sxfz() {
        var dyg14_1 =document.getElementById("dg").rows[0].cells[3].innerText;
        console.log(dyg14_1);
        var dyg14_2 =document.getElementById("dg").rows[0].cells[3].innerHTML;
        console.log(dyg14_2);
        document.getElementById("dg").rows[0].cells[3].innerText = 'ceshi';
        document.getElementById("dg").rows[0].cells[3].innerHTML = 'ceshi1';
    }
</script>
</body>
</html>